package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import com.appwoo.txtws.adapter.ListViewCreator;
import com.appwoo.txtws.adapter.Page;
import com.appwoo.txtws.adapter.SimpleListAdapter;
import com.appwoo.txtws.app.App;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.AutoSoftInfo;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.wheel.widget.PageListView;
import com.appwoo.txtws.wheel.widget.PageListView.OnRefreshListener;
import java.util.List;

public class SetupAppForChildActivity extends AppActivity
{
  private static AutoSoftInfo asi;
  public static Boolean isSendBoradcast = Boolean.valueOf(false);
  private SimpleListAdapter<AutoSoftInfo> adapter;
  private StateBean bean = new StateBean();
  private CheckBox cbCurrent;
  private DBHelper dbHelper;
  private ProgressDialog dialog = null;
  private List<AutoSoftInfo> events;
  private int grantflag = 0;
  private Boolean isFoot = Boolean.valueOf(false);
  private int isHot = 1;
  private PageListView lvList;
  private Page<AutoSoftInfo> page = new Page();
  private PackageManager pm;
  private String softid = "";

  private void initView()
  {
    this.pm = getPackageManager();
    this.dbHelper = new DBHelper(this);
    this.lvList = ((PageListView)findViewById(2131492985));
    this.adapter = new SimpleListAdapter(this.page.getEntries(), new ListViewCreator()
    {
      public View createView(final AutoSoftInfo paramAnonymousAutoSoftInfo, View paramAnonymousView, int paramAnonymousInt)
      {
        if (paramAnonymousView == null)
          paramAnonymousView = App.getLayoutInflater().inflate(2130903119, null);
        ImageView localImageView = (ImageView)paramAnonymousView.findViewById(2131493154);
        TextView localTextView = (TextView)paramAnonymousView.findViewById(2131493155);
        CheckBox localCheckBox = (CheckBox)paramAnonymousView.findViewById(2131493011);
        localTextView.setText(paramAnonymousAutoSoftInfo.getAsname());
        SetupAppForChildActivity.this.grantflag = paramAnonymousAutoSoftInfo.getIsRecd();
        if (SetupAppForChildActivity.this.grantflag == 1)
          localCheckBox.setChecked(true);
        try
        {
          ApplicationInfo localApplicationInfo = SetupAppForChildActivity.this.pm.getApplicationInfo(paramAnonymousAutoSoftInfo.getAspkg(), 8192);
          if ("com.huawei.android.ChinaTelecomCustomize".equals(paramAnonymousAutoSoftInfo.getAspkg()))
            localImageView.setImageDrawable(SetupAppForChildActivity.this.getResources().getDrawable(2130838080));
          while (true)
          {
            localCheckBox.setOnClickListener(new View.OnClickListener()
            {
              public void onClick(View paramAnonymous2View)
              {
                int i = 1;
                SetupAppForChildActivity.this.softid = paramAnonymousAutoSoftInfo.getKeyID();
                SetupAppForChildActivity.this.cbCurrent = ((CheckBox)paramAnonymous2View);
                SetupAppForChildActivity.asi = paramAnonymousAutoSoftInfo;
                SetupAppForChildActivity.asi.setAsIsUpload(i);
                AutoSoftInfo localAutoSoftInfo1 = SetupAppForChildActivity.asi;
                if (SetupAppForChildActivity.asi.getIsRecd() == 0);
                int m;
                for (int k = i; ; m = 0)
                {
                  localAutoSoftInfo1.setIsRecd(k);
                  if (SetupAppForChildActivity.this.dbHelper.updateAuthSofts(SetupAppForChildActivity.asi) <= 0L)
                    break;
                  SetupAppForChildActivity.isSendBoradcast = Boolean.valueOf(i);
                  SetupAppForChildActivity.this.adapter.notifyDataSetChanged();
                  return;
                }
                SetupAppForChildActivity.asi.setAsIsUpload(0);
                AutoSoftInfo localAutoSoftInfo2 = SetupAppForChildActivity.asi;
                if (SetupAppForChildActivity.asi.getIsRecd() == 0);
                while (true)
                {
                  localAutoSoftInfo2.setIsRecd(i);
                  return;
                  int j = 0;
                }
              }
            });
            return paramAnonymousView;
            localCheckBox.setChecked(false);
            break;
            localImageView.setImageDrawable(localApplicationInfo.loadIcon(SetupAppForChildActivity.this.pm));
          }
        }
        catch (PackageManager.NameNotFoundException localNameNotFoundException)
        {
          while (true)
            localNameNotFoundException.printStackTrace();
        }
      }
    });
    this.lvList.setAdapter(this.adapter);
    this.lvList.setOnLoadMoreListener(new PageListView.OnRefreshListener()
    {
      public void onRefresh()
      {
        SetupAppForChildActivity.this.isFoot = Boolean.valueOf(true);
        SetupAppForChildActivity.this.loadingData(false);
      }
    });
    addOperation(new DataTask().execute(new String[] { "installindex" }));
  }

  private void loadingData(boolean paramBoolean)
  {
    if (paramBoolean)
      this.page.firstPage();
    while (true)
    {
      addOperation(new DataTask().execute(new String[] { "installindex" }));
      return;
      this.page.nextPage();
    }
  }

  protected void backKeyCallBack()
  {
    finish();
  }

  public void onBackPressed()
  {
    finish();
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903148);
    initView();
  }

  public void onDestroy()
  {
    super.onDestroy();
    if (isSendBoradcast.booleanValue())
      sendBroadcast(new Intent("refreshData"));
  }

  protected void onResume()
  {
    super.onResume();
  }

  class DataTask extends AsyncTask<String, Integer, Integer>
  {
    String param;

    DataTask()
    {
    }

    protected Integer doInBackground(String[] paramArrayOfString)
    {
      this.param = paramArrayOfString[0];
      RqSP localRqSP = new RqSP();
      localRqSP.getLgDevAccount(SetupAppForChildActivity.this);
      localRqSP.getLgDevId(SetupAppForChildActivity.this);
      if (this.param.equals("installindex"))
        SetupAppForChildActivity.this.events = SetupAppForChildActivity.this.dbHelper.getSoftUploadFirst(0, 5, 0, -1);
      return Integer.valueOf((int)0L);
    }

    protected void onPostExecute(Integer paramInteger)
    {
      if (this.param.equals("installindex"))
      {
        if ((SetupAppForChildActivity.this.events == null) || (SetupAppForChildActivity.this.events.size() <= 0))
          break label133;
        SetupAppForChildActivity.this.page.addAllEntries(SetupAppForChildActivity.this.events);
        SetupAppForChildActivity.this.adapter.notifyDataSetChanged();
        SetupAppForChildActivity.this.lvList.onLoadMoreComplete();
        SetupAppForChildActivity.this.lvList.hideFotterMoreView();
        SetupAppForChildActivity.this.events.clear();
      }
      while (true)
      {
        if (!SetupAppForChildActivity.this.isFoot.booleanValue())
        {
          SetupAppForChildActivity.this.closeProgress();
          SetupAppForChildActivity.this.isFoot = Boolean.valueOf(false);
        }
        super.onPostExecute(paramInteger);
        return;
        label133: SetupAppForChildActivity.this.lvList.hideFotterMoreView();
        SetupAppForChildActivity.this.alertMessage("没有更多数据");
      }
    }

    protected void onPreExecute()
    {
      if (!SetupAppForChildActivity.this.isFoot.booleanValue())
        SetupAppForChildActivity.this.showProgress("");
      super.onPreExecute();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.SetupAppForChildActivity
 * JD-Core Version:    0.6.2
 */